﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace SharePoint.Contrib.Extensions
{
    /// <summary>
    /// Extension methods for the SPFeatureCollection class
    /// </summary>
    public static class SPFeatureCollectionExtensions
    {

        /// <summary>
        /// Removes all the activation dependencies that the SPFeatureReceiverProperties.Definition (aka feature) has.
        /// </summary>
        /// <param name="properties">The SPFeatureReceiver properties</param>
        public static void RemoveActivationDependenciesBy(this SPFeatureCollection instance, SPFeatureReceiverProperties properties)
        {
            var dependencies = properties.ActivationDependenciesForFeature();

            foreach (var dependency in dependencies)
            {
                instance.Remove(dependency, true);
            }
        }
    }
}
